{include file="public/head"/}
<style type="text/css">
    .layui-table-cell{height: auto!important;}
    .layui-layer-tips{width: auto!important;}
    .goods_item{border-bottom: 1px dashed #008B8B;margin-bottom: 5px;padding-top: 5px;}
    .goods_item:last-child{border: none}
    .goods_item div span{padding: 3px;background: #F5F5F5}
    .goods_item div span:first-child{background:none}
    .goods_stance{display: inline-block;width: 30px}
    .goods_thumb{width:30px;height:30px;}
</style>
<div class="layui-fluid" id="LAY-app-message">
    <div class="layui-card">
        <div class="layui-card-header">订单【{$order_id}】【{$order_sn}】核销记录</div>
        <div class="layui-card-body layui-form">
            <div class="table-head-btn" style="margin-bottom: 10px;">
                <div class="layui-inline">
                    <input class="layui-input" name="key" id="key" placeholder="编号" autocomplete="off">
                </div>
                <div class="layui-inline">
                    <input class="layui-input" name="order_id" value="{$order_id}" id="order_id" placeholder="订单编号" autocomplete="off">
                </div>
                <div class="layui-inline">
                    <select name="type" id="type">
                        <option value="">请选择核销者</option>
                        {foreach $people_type as $item}
                        <option value="{$item.type}">{$item.title}</option>
                        {/foreach}
                    </select>
                </div>

                <div class="layui-inline">
                    <input class="layui-input" name="merch_worker" id="merch_worker" placeholder="店员或管理员编号" autocomplete="off">
                </div>

                <div class="layui-inline">
                    <input class="layui-input" name="name" id="name" placeholder="店员姓名或管理员用户名" autocomplete="off">
                </div>

                <div class="layui-inline">
                    <select name="verify_type" id="verify_type">
                        <option value="">请选择核销方式</option>
                        {foreach $verify_type as $item}
                        <option value="{$item.type}">{$item.title}</option>
                        {/foreach}
                    </select>
                </div>

                <div class="layui-inline">
                    <input type="text" name="start_time" class="layui-input" id="start_time"
                           placeholder="开始时间(核销时间)">
                </div>
                <div class="layui-inline">
                    <input type="text" name="end_time" class="layui-input" id="end_time"
                           placeholder="结束时间(核销时间)">
                </div>

                <button class="layui-btn" data-type="reload">搜索</button>
            </div>
            <table class="layui-hide" id="list" lay-filter="list"></table>
        </div>
    </div>
</div>
{include file="public/foot"/}

<script type="text/html" id="type_info">
    {{d.people_type_html}}
</script>

<script type="text/html" id="verify_type_info">
    {{d.verify_type_html}}
</script>

<script>
    layui.config({
        base: '__LAYADMIN__/',
        version: 20220407
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','admin', 'table', 'form','laydate'],function (){
        var $ = layui.$, admin = layui.admin, table = layui.table, form = layui.form, laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#start_time', //指定元素
            type: 'datetime'
        });
        laydate.render({
            elem: '#end_time', //指定元素
            type: 'datetime'
        });

        //全部数据
        tableIn = table.render({
            elem: '#list',
            url: '{:url(\'Order/verifyInfo\',[\'order_id\'=>$order_id])}',
            method: 'post',
            toolbar: '',
            defaultToolbar:[],
            autoSort: false,
            cols: [[
                {field: 'id', title: '编号', width: 80,fixed:true, sort:true},
                {field: 'order_id', title: '订单编号', align:"center", width: 100},
                {field: 'type', title: '核销者', align:"center", width: 130,templet:'#type_info'},
                {field: 'people_id', title: '店员|管理员编号', align:"center", width: 160},
                {field: 'name', title: '店员姓名|管理员用户名', align:"center", width: 160},
                {field: 'verify_type', title: '核销方式', align:"center", width: 130,templet:'#verify_type_info'},
                {field: 'num', title: '核销次数', align:"center", width: 130},
                {field: 'create_time', title: '核销时间', align:"center", width: 180,sort: true},

            ]],
            page: true,
            done: function (res, curr, count) {
                $(".layui-table-header tr").each(function (index, val) {
                    $(".layui-table-fixed").each(function () {
                        $($(this).find(".layui-table-header thead tr")[index]).height($(val).height());
                    });
                });
                $(".layui-table-main tr").each(function (index, val) {
                    $(".layui-table-fixed").each(function () {
                        $($(this).find(".layui-table-body tbody tr")[index]).height($(val).height());
                    });
                });
            }
        });

        //监听排序事件
        table.on('sort(list)', function(obj){
            table.reload('list', {
                initSort: obj
                ,where: {sort_by: obj.field,sort_order: obj.type}
            });
        });


        //监听工具条
        table.on('tool(list)', function (obj) {
            var data = obj.data;
            var id = data.id;

        });

        //监听工具条
        table.on('toolbar(list)', function (obj) {

        });

        var active = {
            reload: function () {
                var search = form.getValue(null,$('.layui-form .table-head-btn'));

                //执行重载
                table.reload('list', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: search
                });
            },
            export: function () {

            }
        };
        $('.table-head-btn .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });
</script>
</body>
</html>